package top.lfyao.designpattern.details.mediator;

/**
 * 抽象同事类
 */
public abstract class Colleague {
    protected Mediator mediator;

    public abstract void send(String message);

    public abstract void receive(String message);

    public Colleague(Mediator mediator) {
        this.mediator = mediator;
    }

}

class ConcreteColleagueA extends Colleague {

    @Override
    public void send(String message) {
        mediator.send(message,this);
    }

    @Override
    public void receive(String message) {
        System.out.println("同事A得到消息：" + message);
    }

    public ConcreteColleagueA(Mediator mediator) {
        super(mediator);
    }
}

class ConcreteColleagueB extends Colleague {

    @Override
    public void send(String message) {
        mediator.send(message,this);
    }

    @Override
    public void receive(String message) {
        System.out.println("同事B得到消息：" + message);
    }

    public ConcreteColleagueB(Mediator mediator) {
        super(mediator);
    }
}
